// // Copyright (c) 2025, 大连理工大学 (Dalian University of Technology)
// //
// // Licensed under the Mulan PSL v2.
// // You can use this file according to the terms and conditions of the Mulan PSL v2.
// // You may obtain a copy of the License at
// //
// //     http://license.coscl.org.cn/MulanPSL2
// //
// // THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
// // EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
// // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. SEE THE MULAN PSL v2
// // FOR MORE DETAILS.

// #include <gtest/gtest.h>

// #include "DBManager/DBAPI.h"
// #include "DBManager/DBServiceFactory.h"
// #include "DBManager/Database/DatabaseFactory.h"
// #include "DBManager/Database/IDatabase.h"
// #include "DBManager/IService/Input/Constraint/IConstraintSummaryService.h"
// #include "DBManager/IService/Input/Constraint/IMPCADDService.h"
// #include "DBManager/IService/Input/Constraint/IMPCService.h"
// #include "DBManager/IService/Input/Constraint/IRBAR1Service.h"
// #include "DBManager/IService/Input/Constraint/IRBARService.h"
// #include "DBManager/IService/Input/Constraint/IRBE1Service.h"
// #include "DBManager/IService/Input/Constraint/IRBE2Service.h"
// #include "DBManager/IService/Input/Constraint/IRElementSummaryService.h"
// #include "DBManager/IService/Input/Constraint/ISPCADDService.h"
// #include "DBManager/IService/Input/Constraint/ISPCService.h"
// #include "DBManager/IService/Input/Coordinate/ICORD1CService.h"
// #include "DBManager/IService/Input/Coordinate/ICORDSummaryService.h"
// #include "DBManager/IService/Input/Dynamic/IDynamicSummaryService.h"
// #include "DBManager/IService/Input/Dynamic/IEIGRLService.h"
// #include "DBManager/IService/Input/Element/ICBARService.h"
// #include "DBManager/IService/Input/Element/ICBEAMService.h"
// #include "DBManager/IService/Input/Element/ICWELDService.h"
// #include "DBManager/IService/Input/Element/IElementService.h"
// #include "DBManager/IService/Input/Load/IFORCEService.h"
// #include "DBManager/IService/Input/Load/ILoadSummaryService.h"
// #include "DBManager/IService/Input/Material/IIsotropicMaterialService.h"
// #include "DBManager/IService/Input/Material/IMAT1FService.h"
// #include "DBManager/IService/Input/Material/IMaterialSummaryService.h"
// #include "DBManager/IService/Input/Material/IOrthotropic2DMaterialService.h"
// #include "DBManager/IService/Input/Node/INodeService.h"
// #include "DBManager/IService/Input/Property/IPBUSHService.h"
// #include "DBManager/IService/Input/Property/IPELASService.h"
// #include "DBManager/IService/Input/Property/IPropertySummaryService.h"
// #include "DBManager/IService/Input/Subcase/ISubcaseService.h"
// #include "DBManager/IService/Input/Table/ITABDMP1Service.h"
// #include "DBManager/IService/Input/Table/ITableSummaryService.h"
// using namespace SG::DBManager;
// using namespace SG::DataStructure::FEM;
// using namespace SG::DataStructure::Common;

// static void AddCBARData (DBServiceFactory* dbf, Id const id)
// {
//     auto service = dbf->get<ICBARService> ();
//     {
//         // 创建对象
//         CBARData obj;
//         obj.m_id   = id;
//         obj.m_g[0] = 1;
//         obj.m_g[1] = 2;

//         // 添加对象
//         service->Add (obj);
//     }
//     {
//         // 创建对象
//         CBARData obj;
//         obj.m_id   = (id + 1);
//         obj.m_g[0] = 3;
//         obj.m_g[1] = 4;
//         // 添加对象
//         service->Add (obj);
//     }

//     ASSERT_EQ (service->Size (), 2);
// }

// static void AddCBEAMData (DBServiceFactory* dbf, Id const id)
// {
//     auto service = dbf->get<ICBEAMService> ();
//     {
//         // 创建对象
//         CBEAMData obj;
//         obj.m_id   = id;
//         obj.m_g[0] = 1;
//         obj.m_g[1] = 2;

//         // 添加对象
//         service->Add (obj);
//     }

//     CBEAMData x;
//     service->FindByIndex (0, x);
//     ASSERT_EQ (x.m_id, id);
// }

// static void AddCORD1C (DBServiceFactory* dbf, Id const id)
// {
//     // 创建对象
//     SG::DataStructure::FEM::CORD1CData obj;
//     obj.m_id = id;

//     // 获取服务
//     auto service = dbf->get<SG::DBManager::ICORD1CService> ();
//     // 添加对象
//     service->Add (obj);

//     ASSERT_EQ (service->Size (), 1);
//     ASSERT_EQ (service->FindById (id, obj), SG::DataStructure::Common::Status::STATUS_Success);
//     ASSERT_EQ (obj.m_id, id);
//     ASSERT_EQ (service->GetAllId ().size (), 1);
// }

// static void AddConstraint (DBServiceFactory* dbf, Id const sId)
// {
//     // 对MPC数据的处理
//     // 先添加MPC
//     SG::DataStructure::FEM::MPCData mpc;
//     mpc.m_sId       = sId;
//     mpc.m_slaveItem = SG::DataStructure::FEM::MPCData::MPCComponent ();
//     // mpc.m_Y         = 1;
//     dbf->get<IMPCService> ()->Add (mpc);
//     // 后链接MPCADD
//     SG::DataStructure::FEM::MPCADDData mpcadd;
//     mpcadd.m_sId     = sId;
//     mpcadd.m_subSets = { sId };
//     dbf->get<IMPCADDService> ()->Add (mpcadd);

//     // 对SPC数据的处理
//     // 先添加SPC
//     SG::DataStructure::FEM::SPCData spc;
//     spc.m_sId = sId;
//     spc.m_g   = 1;
//     dbf->get<ISPCService> ()->Add (spc);

//     // 后链接SPCADD
//     SG::DataStructure::FEM::SPCADDData spcadd;
//     spcadd.m_sId     = sId;
//     spcadd.m_subSets = { sId };
//     dbf->get<ISPCADDService> ()->Add (spcadd);
// }

// static void AddRElement (DBServiceFactory* dbf, Id id)
// {
//     {  // 创建对象
//         SG::DataStructure::FEM::RBAR1Data obj;
//         obj.m_id = id;

//         // 获取服务
//         auto service = dbf->get<IRBAR1Service> ();
//         // 添加对象
//         service->Add (obj);

//         ASSERT_EQ (service->Size (), 1);
//         ASSERT_EQ (service->FindById (id, obj), SG::DataStructure::Common::Status::STATUS_Success);
//         ASSERT_EQ (obj.m_id, id);
//         ASSERT_EQ (service->GetAllId ().size (), 1);
//     }

//     {
//         id++;
//         // 创建对象
//         SG::DataStructure::FEM::RBARData obj;
//         obj.m_id = id;

//         // 获取服务
//         auto service = dbf->get<IRBARService> ();
//         // 添加对象
//         service->Add (obj);

//         ASSERT_EQ (service->Size (), 1);
//         ASSERT_EQ (service->FindById (id, obj), SG::DataStructure::Common::Status::STATUS_Success);
//         ASSERT_EQ (obj.m_id, id);
//         ASSERT_EQ (service->GetAllId ().size (), 1);
//     }

//     {
//         id++;
//         // 创建对象
//         SG::DataStructure::FEM::RBE1Data obj;
//         obj.m_id = id;

//         // 获取服务
//         auto service = dbf->get<IRBE1Service> ();
//         // 添加对象
//         service->Add (obj);

//         ASSERT_EQ (service->Size (), 1);

//         ASSERT_EQ (service->FindById (id, obj), SG::DataStructure::Common::Status::STATUS_Success);
//         ASSERT_EQ (obj.m_id, id);
//         ASSERT_EQ (service->GetAllId ().size (), 1);
//     }

//     {
//         id++;
//         // 创建对象
//         SG::DataStructure::FEM::RBE2Data obj;
//         obj.m_id = id;

//         // 获取服务
//         auto service = dbf->get<IRBE2Service> ();
//         // 添加对象
//         service->Add (obj);

//         ASSERT_EQ (service->Size (), 1);
//         ASSERT_EQ (service->FindById (id, obj), SG::DataStructure::Common::Status::STATUS_Success);
//         ASSERT_EQ (obj.m_id, id);
//         ASSERT_EQ (service->GetAllId ().size (), 1);
//     }
// }

// static void AddMaterial (DBServiceFactory* dbf, Id id)
// {
//     {
//         IsotropicMaterial x;
//         x.m_id       = id;
//         auto service = dbf->get<IIsotropicMaterialService> ();
//         service->Add (x);
//         ASSERT_EQ (service->Size (), 1);
//     }
//     {
//         IMAT1FService::ServiceDataType x;
//         x.m_id       = id;
//         auto service = dbf->get<IMAT1FService> ();
//         service->Add (x);
//         ASSERT_EQ (service->Size (), 1);
//     }
//     {
//         Orthotropic2DMaterial x;
//         x.m_id       = ++id;
//         auto service = dbf->get<IOrthotropic2DMaterialService> ();
//         service->Add (x);
//         x.m_id = ++id;
//         service->Add (x);
//         ASSERT_EQ (service->Size (), 2);
//     }

//     auto summaryService = dbf->get<IMaterialSummaryService> ();
//     ASSERT_EQ (summaryService->GetMaterialType (id)[0], Orthotropic2DMaterial::GetType ());
// }

// static void AddProperty (DBServiceFactory* dbf, Id id)
// {
//     {
//         // 创建对象
//         PBUSHData obj;
//         obj.m_id = id;

//         // 获取服务
//         auto service = dbf->get<IPBUSHService> ();
//         // 添加对象
//         service->Add (obj);

//         ASSERT_EQ (service->Size (), 1);
//         ASSERT_EQ (service->FindById (id, obj), SG::DataStructure::Common::Status::STATUS_Success);
//         ASSERT_EQ (obj.m_id, id);
//         ASSERT_EQ (service->GetAllId ().size (), 1);
//     }

//     {
//         // 创建对象
//         PELASData obj;
//         obj.m_id = ++id;

//         // 获取服务
//         auto service = dbf->get<IPELASService> ();
//         // 添加对象
//         service->Add (obj);

//         ASSERT_EQ (service->Size (), 1);
//     }

//     auto summaryService = dbf->get<IPropertySummaryService> ();
//     ASSERT_EQ (summaryService->GetPropertyType (id), PropertyTypes::PROTYPE_PELAS);
// }

// static void AddDynamic (DBServiceFactory* dbf, Id id)
// {
//     // 获取服务
//     auto service = dbf->get<IEIGRLService> ();

//     // 创建对象
//     EIGRLData obj;
//     obj.m_sId     = id;
//     obj.m_ND      = 10;
//     obj.m_NORM[0] = 'M';
//     obj.m_NORM[1] = 'A';
//     obj.m_NORM[2] = 'S';
//     obj.m_NORM[3] = 'S';

//     // 添加对象
//     service->Add (obj);
//     obj.m_sId     = 9;
//     obj.m_ND      = 10;
//     obj.m_NORM[0] = 'M';
//     obj.m_NORM[1] = 'A';
//     obj.m_NORM[2] = 'X';
//     obj.m_NORM[3] = '\0';
//     service->Add (obj);
//     ASSERT_EQ (service->Size (), 2);

//     EIGRLData data;
//     ASSERT_EQ (service->FindBySId (id, data), SG::DataStructure::Common::Status::STATUS_Success);
//     ASSERT_EQ (data.m_sId, id);
//     ASSERT_EQ (data.GetMNEType (), EIGRLData::MASS);

//     ASSERT_EQ (service->FindBySId (9, data), SG::DataStructure::Common::Status::STATUS_Success);
//     ASSERT_EQ (data.m_sId, 9);
//     ASSERT_EQ (data.GetMNEType (), EIGRLData::DISP);
// }

// static void AddLoad (DBServiceFactory* dbf, Id id)
// {
//     // 创建对象
//     FORCEData obj;
//     obj.m_sId = id;

//     // 获取服务
//     auto service = dbf->get<IFORCEService> ();
//     // 添加对象
//     service->Add (obj);

//     ASSERT_EQ (service->Size (), 1);

//     std::vector<FORCEData> results;
//     // FindBySId
//     service->FindBySId (id, results);
//     ASSERT_EQ (results.size (), 1);
//     ASSERT_EQ (results[0].m_sId, id);
// }

// static void AddTable (DBServiceFactory* dbf, Id id)
// {
//     auto service = dbf->get<ITABDMP1Service> ();

//     SG::DataStructure::FEM::TABDMP1Data data;
//     data.m_id = id;
//     ASSERT_EQ (service->Add (data), SG::DataStructure::Common::Status::STATUS_Success);

//     SG::DataStructure::FEM::TABDMP1Data _OUT outData;
//     ASSERT_EQ (service->FindById (id, outData), SG::DataStructure::Common::Status::STATUS_Success);
//     ASSERT_EQ (outData.m_id, id);

//     ASSERT_EQ (service->FindByIndex (0, outData), SG::DataStructure::Common::Status::STATUS_Success);
//     ASSERT_EQ (outData.m_id, id);

//     ASSERT_EQ (service->Size (), 1);
//     ASSERT_EQ (service->Count (id), 1);
// }

// static void AddSubcase (DBServiceFactory* dbf)
// {
//     auto service = dbf->get<ISubcaseService> ();
//     service->Initial (SG::Utility::SGParameter (R"({
//             "1": {
//                 "SOL": {
//                     "MAIN_KEY": "101"
//                 },
//                 "DISPLACEMENT": {
//                     "MAIN_KEY": "ALL"
//                 },
//                 "LOAD": {
//                     "MAIN_KEY": "1"
//                 },
//                 "SPC": {
//                     "MAIN_KEY": "1"
//                 },
//                 "STRAIN": {
//                     "MAIN_KEY": "ALL"
//                 },
//                 "STRESS": {
//                     "MAIN_KEY": "ALL"
//                 },
//                 "SUBCASE": {
//                     "MAIN_KEY": "1"
//                 }
//             }
//         }
//         )"));
// }

// TEST (MultipleDBTest, MultipleDB)
// {
//     // 数据库工厂
//     auto databaseFactory = std::make_shared<DatabaseFactory> ();

//     // 数据库
//     IDatabase* db1 = databaseFactory->GetDatabase (DatabaseFactory::HDF5, ".", "DBManagerMultipleDBTest1.db");
//     IDatabase* db2 = databaseFactory->GetDatabase (DatabaseFactory::HDF5, ".", "DBManagerMultipleDBTest2.db");
//     IDatabase* db3 = databaseFactory->GetDatabase (DatabaseFactory::HDF5, ".", "DBManagerMultipleDBTest3.db");

//     // 根据数据库创建Service管理器
//     auto dbserviceFactory1 = std::make_shared<DBServiceFactory> (db1);
//     auto dbserviceFactory2 = std::make_shared<DBServiceFactory> (db2);
//     auto dbserviceFactory3 = std::make_shared<DBServiceFactory> (db3);
//     dbserviceFactory1->ClearDatabase ();
//     dbserviceFactory2->ClearDatabase ();
//     dbserviceFactory3->ClearDatabase ();

//     // 组织基本数据
//     {
//         AddCBARData (dbserviceFactory1.get (), 123);
//         AddCBARData (dbserviceFactory2.get (), 234);
//         AddCBARData (dbserviceFactory3.get (), 345);

//         AddCBEAMData (dbserviceFactory1.get (), 1234);
//         AddCBEAMData (dbserviceFactory2.get (), 2345);
//         AddCBEAMData (dbserviceFactory3.get (), 3456);

//         AddCORD1C (dbserviceFactory1.get (), 100);
//         AddConstraint (dbserviceFactory1.get (), 200);
//         AddRElement (dbserviceFactory1.get (), 300);

//         AddMaterial (dbserviceFactory1.get (), 400);
//         AddProperty (dbserviceFactory1.get (), 500);

//         AddDynamic (dbserviceFactory1.get (), 600);
//         AddLoad (dbserviceFactory1.get (), 700);
//         AddTable (dbserviceFactory1.get (), 800);

//         AddSubcase (dbserviceFactory1.get ());
//     }

//     // 测试Element
//     {
//         // 将数据库数据复制到另一个数据库
//         SG::DBManager::DBAPI::CopyData (dbserviceFactory1.get (), dbserviceFactory2.get (), DataTableType::DT_ELEMENT, { 123, 124 });

//         auto sumService1 = dbserviceFactory1->get<IElementService> ();
//         auto sumService2 = dbserviceFactory2->get<IElementService> ();
//         auto sumService3 = dbserviceFactory3->get<IElementService> ();

//         // FindElementNodes
//         ASSERT_EQ (sumService1->FindElementNodes (123).size (), 2);
//         ASSERT_EQ (sumService1->FindElementNodes (124).size (), 2);
//         ASSERT_EQ (sumService2->FindElementNodes (123).size (), 2);
//         ASSERT_EQ (sumService2->FindElementNodes (124).size (), 2);
//         ASSERT_EQ (sumService2->FindElementNodes (234).size (), 2);
//         ASSERT_EQ (sumService2->FindElementNodes (235).size (), 2);
//         ASSERT_EQ (sumService3->FindElementNodes (345).size (), 2);
//         ASSERT_EQ (sumService3->FindElementNodes (346).size (), 2);

//         ASSERT_EQ (sumService1->FindElementNodes (1234).size (), 2);
//         ASSERT_EQ (sumService2->FindElementNodes (2345).size (), 2);
//         ASSERT_EQ (sumService3->FindElementNodes (3456).size (), 2);

//         const std::vector<ElementTypes> types1 = sumService1->GetAllElementTypes ();
//         const std::vector<ElementTypes> types2 = sumService2->GetAllElementTypes ();
//         const std::vector<ElementTypes> types3 = sumService3->GetAllElementTypes ();
//         ASSERT_EQ (types1[0], ElementTypes::ELETYPE_Bar);
//         ASSERT_EQ (types1[1], ElementTypes::ELETYPE_Beam);
//         ASSERT_EQ (types2[0], ElementTypes::ELETYPE_Bar);
//         ASSERT_EQ (types2[1], ElementTypes::ELETYPE_Beam);
//         ASSERT_EQ (types3[0], ElementTypes::ELETYPE_Bar);
//         ASSERT_EQ (types3[1], ElementTypes::ELETYPE_Beam);

//         ASSERT_EQ (sumService1->GetElementType (123), ElementTypes::ELETYPE_Bar);
//         ASSERT_EQ (sumService1->GetElementType (124), ElementTypes::ELETYPE_Bar);
//         ASSERT_EQ (sumService2->GetElementType (123), ElementTypes::ELETYPE_Bar);
//         ASSERT_EQ (sumService2->GetElementType (124), ElementTypes::ELETYPE_Bar);
//         ASSERT_EQ (sumService2->GetElementType (234), ElementTypes::ELETYPE_Bar);
//         ASSERT_EQ (sumService2->GetElementType (235), ElementTypes::ELETYPE_Bar);
//         ASSERT_EQ (sumService3->GetElementType (345), ElementTypes::ELETYPE_Bar);
//         ASSERT_EQ (sumService3->GetElementType (346), ElementTypes::ELETYPE_Bar);

//         ASSERT_EQ (sumService1->GetElementType (1234), ElementTypes::ELETYPE_Beam);
//         ASSERT_EQ (sumService2->GetElementType (2345), ElementTypes::ELETYPE_Beam);
//         ASSERT_EQ (sumService3->GetElementType (3456), ElementTypes::ELETYPE_Beam);

//         ASSERT_EQ (sumService1->GetElementSize (ElementTypes::ELETYPE_Bar), 2);
//         ASSERT_EQ (sumService2->GetElementSize (ElementTypes::ELETYPE_Bar), 4);
//         ASSERT_EQ (sumService3->GetElementSize (ElementTypes::ELETYPE_Bar), 2);
//         ASSERT_EQ (sumService1->GetElementSize (ElementTypes::ELETYPE_Beam), 1);
//         ASSERT_EQ (sumService2->GetElementSize (ElementTypes::ELETYPE_Beam), 1);
//         ASSERT_EQ (sumService3->GetElementSize (ElementTypes::ELETYPE_Beam), 1);

//         SG::Algebra::Matrix m1 = sumService1->GetElementNodes (ElementTypes::ELETYPE_Beam);
//         ASSERT_EQ (m1[0][0], 1);
//         ASSERT_EQ (m1[0][1], 2);

//         SG::Algebra::Matrix m2 = sumService2->GetElementNodes (ElementTypes::ELETYPE_Beam);
//         ASSERT_EQ (m2[0][0], 1);
//         ASSERT_EQ (m2[0][1], 2);

//         SG::Algebra::Matrix m3 = sumService3->GetElementNodes (ElementTypes::ELETYPE_Beam);
//         ASSERT_EQ (m3[0][0], 1);
//         ASSERT_EQ (m3[0][1], 2);

//         // 测试FindElement
//         ASSERT_EQ (sumService1->FindElement (123).second, 0);
//         ASSERT_EQ (sumService1->FindElement (124).second, 1);
//         ASSERT_EQ (sumService2->FindElement (123).second, 0);
//         ASSERT_EQ (sumService2->FindElement (124).second, 1);
//         ASSERT_EQ (sumService2->FindElement (234).second, 2);
//         ASSERT_EQ (sumService2->FindElement (235).second, 3);
//         ASSERT_EQ (sumService3->FindElement (345).second, 0);
//         ASSERT_EQ (sumService3->FindElement (346).second, 1);
//     }

//     // 测试坐标
//     {
//         // 将数据库数据复制到另一个数据库
//         SG::DBManager::DBAPI::CopyData (dbserviceFactory1.get (), dbserviceFactory2.get (), DataTableType::DT_COORDINATE, { 100 });

//         auto sumService1 = dbserviceFactory1->get<ICORDSummaryService> ();
//         auto sumService2 = dbserviceFactory2->get<ICORDSummaryService> ();

//         ASSERT_TRUE (sumService1->Size () == 1);
//         ASSERT_TRUE (sumService2->Size () == 1);

//         ASSERT_TRUE (sumService1->GetAllCoordinate ().size () == 1);
//         ASSERT_TRUE (sumService2->GetAllCoordinate ().size () == 1);

//         CORD1CData cord1;
//         CORD1CData cord2;

//         auto cord1cService1 = dbserviceFactory1->get<ICORD1CService> ();
//         auto cord1cService2 = dbserviceFactory2->get<ICORD1CService> ();

//         ASSERT_EQ (cord1cService1->FindById (100, cord1), SG::DataStructure::Common::Status::STATUS_Success);
//         ASSERT_EQ (cord1cService2->FindById (100, cord2), SG::DataStructure::Common::Status::STATUS_Success);

//         ASSERT_EQ (cord1, cord2);
//     }

//     // 测试约束
//     {
//         // 将数据库数据复制到另一个数据库
//         SG::DBManager::DBAPI::CopyData (dbserviceFactory1.get (), dbserviceFactory2.get (), DataTableType::DT_CONSTRAINT, { 200 });

//         auto sumService1 = dbserviceFactory1->get<IConstraintSummaryService> ();
//         auto sumService2 = dbserviceFactory2->get<IConstraintSummaryService> ();

//         std::vector<IMPCADDService::ServiceDataType> data1;
//         std::vector<IMPCADDService::ServiceDataType> data2;

//         auto service1 = dbserviceFactory1->get<IMPCADDService> ();
//         auto service2 = dbserviceFactory2->get<IMPCADDService> ();

//         ASSERT_EQ (service1->FindBySId (200, data1), SG::DataStructure::Common::Status::STATUS_Success);
//         ASSERT_EQ (service2->FindBySId (200, data2), SG::DataStructure::Common::Status::STATUS_Success);

//         ASSERT_EQ (data1, data2);
//         ASSERT_EQ (sumService1->GetAllId (), SG::DataStructure::Common::IdArray{ 200 });

//         auto types1 = sumService1->GetType (200);
//         auto types2 = sumService2->GetType (200);
//         ASSERT_EQ (types1, types2);
//     }

//     // 测试R单元
//     {
//         auto service11 = dbserviceFactory1->get<IRBAR1Service> ();
//         auto service12 = dbserviceFactory1->get<IRBARService> ();
//         auto service13 = dbserviceFactory1->get<IRBE1Service> ();
//         auto service14 = dbserviceFactory1->get<IRBE2Service> ();
//         auto service21 = dbserviceFactory2->get<IRBAR1Service> ();
//         auto service22 = dbserviceFactory2->get<IRBARService> ();
//         auto service33 = dbserviceFactory3->get<IRBE1Service> ();
//         auto service34 = dbserviceFactory3->get<IRBE2Service> ();

//         auto sumService1 = dbserviceFactory1->get<IRElementSummaryService> ();
//         ASSERT_EQ (sumService1->GetAllRElementId ().size (), 4);

//         // 将数据库数据复制到另一个数据库
//         SG::DBManager::DBAPI::CopyData (dbserviceFactory1.get (), dbserviceFactory2.get (), DataTableType::DT_RELEMENT, { 300, 301 });
//         SG::DBManager::DBAPI::CopyData (dbserviceFactory1.get (), dbserviceFactory3.get (), DataTableType::DT_RELEMENT, { 302, 303 });

//         auto sumService2 = dbserviceFactory2->get<IRElementSummaryService> ();
//         auto sumService3 = dbserviceFactory3->get<IRElementSummaryService> ();

//         ASSERT_EQ (sumService2->GetAllRElementId ().size (), 2);
//         ASSERT_EQ (sumService3->GetAllRElementId ().size (), 2);

//         IRBAR1Service::ServiceDataType data11;
//         IRBARService::ServiceDataType  data12;
//         IRBAR1Service::ServiceDataType data21;
//         IRBARService::ServiceDataType  data22;
//         IRBE1Service::ServiceDataType  data13;
//         IRBE2Service::ServiceDataType  data14;
//         IRBE1Service::ServiceDataType  data33;
//         IRBE2Service::ServiceDataType  data34;

//         ASSERT_EQ (service11->FindById (300, data11), SG::DataStructure::Common::Status::STATUS_Success);
//         ASSERT_EQ (service12->FindById (301, data12), SG::DataStructure::Common::Status::STATUS_Success);
//         ASSERT_EQ (service21->FindById (300, data21), SG::DataStructure::Common::Status::STATUS_Success);
//         ASSERT_EQ (service22->FindById (301, data22), SG::DataStructure::Common::Status::STATUS_Success);

//         ASSERT_EQ (service13->FindById (302, data13), SG::DataStructure::Common::Status::STATUS_Success);
//         ASSERT_EQ (service14->FindById (303, data14), SG::DataStructure::Common::Status::STATUS_Success);
//         ASSERT_EQ (service33->FindById (302, data33), SG::DataStructure::Common::Status::STATUS_Success);
//         ASSERT_EQ (service34->FindById (303, data34), SG::DataStructure::Common::Status::STATUS_Success);

//         ASSERT_EQ (data11, data21);
//         ASSERT_EQ (data12, data22);
//         ASSERT_EQ (data13, data33);
//         ASSERT_EQ (data14, data34);
//     }

//     // 测试材料
//     {
//         // 将数据库数据复制到另一个数据库
//         SG::DBManager::DBAPI::CopyData (dbserviceFactory1.get (), dbserviceFactory2.get (), DataTableType::DT_MATERIAL, { 400, 401, 402 });

//         auto sumService1 = dbserviceFactory1->get<IMaterialSummaryService> ();
//         auto sumService2 = dbserviceFactory2->get<IMaterialSummaryService> ();

//         auto typs1 = sumService1->GetMaterialType (400);
//         auto typs2 = sumService2->GetMaterialType (400);
//         ASSERT_TRUE (typs1.size () == 2);
//         ASSERT_TRUE (typs2.size () == 2);

//         {
//             MAT1FData data1;
//             MAT1FData data2;

//             auto service1 = dbserviceFactory1->get<IMAT1FService> ();
//             auto service2 = dbserviceFactory2->get<IMAT1FService> ();

//             ASSERT_EQ (service1->FindById (400, data1), SG::DataStructure::Common::Status::STATUS_Success);
//             ASSERT_EQ (service2->FindById (400, data2), SG::DataStructure::Common::Status::STATUS_Success);

//             ASSERT_EQ (data1, data2);
//         }
//         {
//             IsotropicMaterial data1;
//             IsotropicMaterial data2;

//             auto service1 = dbserviceFactory1->get<IIsotropicMaterialService> ();
//             auto service2 = dbserviceFactory2->get<IIsotropicMaterialService> ();

//             ASSERT_EQ (service1->FindById (400, data1), SG::DataStructure::Common::Status::STATUS_Success);
//             ASSERT_EQ (service2->FindById (400, data2), SG::DataStructure::Common::Status::STATUS_Success);

//             ASSERT_EQ (data1, data2);
//         }
//     }

//     // 测试属性
//     {
//         // 将数据库数据复制到另一个数据库
//         SG::DBManager::DBAPI::CopyData (dbserviceFactory1.get (), dbserviceFactory2.get (), DataTableType::DT_PROPERTY, { 500, 501 });

//         auto sumService1 = dbserviceFactory1->get<IPropertySummaryService> ();
//         auto sumService2 = dbserviceFactory2->get<IPropertySummaryService> ();

//         auto typs1 = sumService1->GetPropertyType (500);
//         auto typs2 = sumService2->GetPropertyType (501);
//         ASSERT_TRUE (typs1 == PropertyTypes::PROTYPE_PBUSH);
//         ASSERT_TRUE (typs2 == PropertyTypes::PROTYPE_PELAS);

//         {
//             PBUSHData data1;
//             PBUSHData data2;

//             auto service1 = dbserviceFactory1->get<IPBUSHService> ();
//             auto service2 = dbserviceFactory2->get<IPBUSHService> ();

//             ASSERT_EQ (service1->FindById (500, data1), SG::DataStructure::Common::Status::STATUS_Success);
//             ASSERT_EQ (service2->FindById (500, data2), SG::DataStructure::Common::Status::STATUS_Success);

//             ASSERT_EQ (data1, data2);
//         }
//         {
//             PELASData data1;
//             PELASData data2;

//             auto service1 = dbserviceFactory1->get<IPELASService> ();
//             auto service2 = dbserviceFactory2->get<IPELASService> ();

//             ASSERT_EQ (service1->FindById (501, data1), SG::DataStructure::Common::Status::STATUS_Success);
//             ASSERT_EQ (service2->FindById (501, data2), SG::DataStructure::Common::Status::STATUS_Success);

//             ASSERT_EQ (data1, data2);
//         }
//     }

//     // 测试动力学
//     {
//         // 将数据库数据复制到另一个数据库
//         SG::DBManager::DBAPI::CopyData (dbserviceFactory1.get (), dbserviceFactory2.get (), DataTableType::DT_DYNAMIC, { 600 });
//         auto sumService1 = dbserviceFactory1->get<IDynamicSummaryService> ();
//         auto sumService2 = dbserviceFactory2->get<IDynamicSummaryService> ();

//         auto typs1 = sumService1->GetDynamicType (600);
//         auto typs2 = sumService2->GetDynamicType (600);
//         ASSERT_TRUE (typs1 == typs2);
//         ASSERT_TRUE (typs1.size () == 1);

//         {
//             EIGRLData data1;
//             EIGRLData data2;

//             auto service1 = dbserviceFactory1->get<IEIGRLService> ();
//             auto service2 = dbserviceFactory2->get<IEIGRLService> ();

//             ASSERT_EQ (service1->FindBySId (600, data1), SG::DataStructure::Common::Status::STATUS_Success);
//             ASSERT_EQ (service2->FindBySId (600, data2), SG::DataStructure::Common::Status::STATUS_Success);

//             ASSERT_EQ (data1, data2);
//         }
//     }
//     // 测试Load
//     {
//         // 将数据库数据复制到另一个数据库
//         SG::DBManager::DBAPI::CopyData (dbserviceFactory1.get (), dbserviceFactory2.get (), DataTableType::DT_LOAD, { 700 });
//         auto sumService1 = dbserviceFactory1->get<ILoadSummaryService> ();
//         auto sumService2 = dbserviceFactory2->get<ILoadSummaryService> ();

//         auto typs1 = sumService1->GetLoadType (700);
//         auto typs2 = sumService2->GetLoadType (700);
//         ASSERT_TRUE (typs1 == typs2);
//         ASSERT_TRUE (typs1.size () == 1);

//         {
//             std::vector<FORCEData> data1;
//             std::vector<FORCEData> data2;

//             auto service1 = dbserviceFactory1->get<IFORCEService> ();
//             auto service2 = dbserviceFactory2->get<IFORCEService> ();

//             ASSERT_EQ (service1->FindBySId (700, data1), SG::DataStructure::Common::Status::STATUS_Success);
//             ASSERT_EQ (service2->FindBySId (700, data2), SG::DataStructure::Common::Status::STATUS_Success);

//             ASSERT_EQ (data1, data2);
//         }
//     }
//     // 测试Table
//     {  // 将数据库数据复制到另一个数据库
//         SG::DBManager::DBAPI::CopyData (dbserviceFactory1.get (), dbserviceFactory2.get (), DataTableType::DT_TABLE, { 800 });
//         auto sumService1 = dbserviceFactory1->get<ITableSummaryService> ();
//         auto sumService2 = dbserviceFactory2->get<ITableSummaryService> ();

//         auto typs1 = sumService1->GetTableType (800);
//         auto typs2 = sumService2->GetTableType (800);
//         ASSERT_EQ (typs1, typs2);
//         ASSERT_EQ (typs1, TableTypes::TABLETYPE_TABDMP1);

//         {
//             TABDMP1Data data1;
//             TABDMP1Data data2;

//             auto service1 = dbserviceFactory1->get<ITABDMP1Service> ();
//             auto service2 = dbserviceFactory2->get<ITABDMP1Service> ();

//             ASSERT_EQ (service1->FindById (800, data1), SG::DataStructure::Common::Status::STATUS_Success);
//             ASSERT_EQ (service2->FindById (800, data2), SG::DataStructure::Common::Status::STATUS_Success);

//             ASSERT_EQ (data1, data2);
//         }
//     }
//     // 测试Subcase
//     {  // 将数据库数据复制到另一个数据库

//         auto subcaseService1 = dbserviceFactory1->get<ISubcaseService> ();
//         auto subcaseService2 = dbserviceFactory2->get<ISubcaseService> ();

//         // for (auto&& subcaseId : subcaseService1->GetAllSubcaseID ())
//         // {
//         SG::DBManager::DBAPI::CopySubcaseData (dbserviceFactory1.get (), dbserviceFactory2.get ());
//         // }

//         ASSERT_EQ (subcaseService1->GetSubcase ().WriteJsonString (), subcaseService2->GetSubcase ().WriteJsonString ());
//     }

//     // 保存数据库
//     dbserviceFactory1->SaveDatabase ();
//     dbserviceFactory2->SaveDatabase ();
//     dbserviceFactory3->SaveDatabase ();
//     databaseFactory->DestroyDatabase (db1);
//     databaseFactory->DestroyDatabase (db2);
//     databaseFactory->DestroyDatabase (db3);
// }